# -*- coding: utf-8 -*-
# @Time    : 2022/4/23 17:25
# @Author  : Zhy
# @Email   : mat_wu@163.com
# @File    : mytoken.py
# @Software: PyCharm
import jwt

class Myjwt:
    def __init__(self):
        self.Secret = 'dsadasdasdas'
    def jwt_token(self,data):
        return jwt.encode(data,self.Secret,algorithm='HS256')
    def verify_token(self,token):
        return jwt.decode(token,self.Secret,algorithms='HS256')
    def check_token(self,token):
        payload = jwt.decode(token,self.Secret,algorithms='HS256')
        tokens = jwt.encode(payload,self.Secret,algorithm='HS256')
        if token == tokens:
            return True
        else:
            return False

myjwt = Myjwt()
data = {"name":"张三"}
token = myjwt.jwt_token(data)
print(token)
payload = myjwt.verify_token(token)
print(payload)
aa = myjwt.check_token(token)
print(aa)


